package com.bsj.power.common.def.dto.video;

import com.bsj.power.common.def.dto.media.UploadParam;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;

import java.io.UnsupportedEncodingException;

/**
 * @Description 打包指令下发指令
 * @Author zhaoyang
 * @Date 2023/6/19 14:34
 */
@Slf4j
public class PacketIssueCmd {

    /**
     * 实时视频请求 9101
     *
     * @param request
     * @return
     */
    @SneakyThrows
    public static byte[] packet9101Cmd(RealVideoRequest request)  {
        if (request == null) {
            return null;
        }
        return GenerateBodyUtil.generate9101(request);
    }

    /***
     * 视频回放 9201
     *
     * @param request
     * @return
     */
    @SneakyThrows
    public static byte[] packet9201Cmd(BackVodRequest request) {
        if (request == null) {
            log.error("视频回放请求参数为空");
            return null;
        }
        return GenerateBodyUtil.generate9201(request);
    }

    /**
     * 实时视频控制(关闭) 9102
     *
     * @param request
     * @return
     */
    public static byte[] packet9102Cmd(RealVideoControl request) {
        if (request == null) {
            log.error("实时视频控制请求参数为空");
            return null;
        }
        return GenerateBodyUtil.generate9102(request);
    }

    /**
     * 录像回放控制(关闭) 9202
     *
     * @param request
     * @return
     */
    public static byte[] packet9202Cmd(BackVodControl request) {
        if (request == null) {
            log.error("录像回放控制请求参数为空");
            return null;
        }
        return GenerateBodyUtil.generate9202(request);
    }

    /**
     * 录像回放资源列表查询 9205
     *
     * @param request
     * @return
     */
    public static byte[] packet9205Cmd(ResouceParam request) {
        if (request == null) {
            log.error("录像回放控制请求参数为空");
            return null;
        }
        return GenerateBodyUtil.generate9205(request);
    }

    /**
     * 文件上传
     *
     * @param param
     * @param ftpProperties
     * @return
     */
    public static byte[] packet9206Cmd(UploadParam param, FtpProperties ftpProperties) {
        if (param == null || ftpProperties == null) {
            log.error("文件上传请求参数为空");
            return null;
        }
        return GenerateBodyUtil.handle9206Body(param, ftpProperties);
    }

    /**
     * 录像回放资源列表查询 9A05（9205 GH版本）
     *
     * @param request
     * @return
     */
    public static byte[] packet9A05Cmd(GHResouceParam request) throws UnsupportedEncodingException {
        if (request == null) {
            log.error("9A05录像回放控制请求参数为空");
            return null;
        }
        return GenerateBodyUtil.generate9A05(request);
    }

}
